
#pragma once
//#include "AbstractItemModel.h"

#include <deque>

namespace DuiLib
{

	class UILIB_API CCommonListModel : public CAbstractItemModel
	{
		typedef std::deque<CVar> VarLine;
		typedef std::deque<VarLine> VarMatrix;

	public:
		CCommonListModel() = delete;
		CCommonListModel(int rows, int cols);
		~CCommonListModel();

		bool hasIndex(int row, int col, const CModelIndex& parent = CModelIndex()) const;
		CModelIndex index(int row, int col, const CModelIndex& parent = CModelIndex()) const;
		CModelIndex sibling(int row, int col, const CModelIndex& idx) const;

		CModelIndex parent(const CModelIndex& child) const;
		bool hasChild(const CModelIndex& parent = CModelIndex()) const;

		int rowCount(const CModelIndex& parent = CModelIndex()) const;
		int columnCount(const CModelIndex& parent = CModelIndex()) const;

		CVar data(const CModelIndex& index) const;
		bool setData(const CModelIndex& index, const CVar& var);

		CVar headerData(int section, Orientation orient) const;
		bool setHeaderData(int section, Orientation orient, const CVar& var);

		bool insertRows(int row, int count, const CModelIndex& parent = CModelIndex());
		bool removeRows(int row, int count, const CModelIndex& parent = CModelIndex());

		bool removeAll();

	private:
		void initHeadData();

	private:
		VarLine m_HeadData;

		VarMatrix m_Data;

		int m_ColumnCount;
	};

}